package com.fourforfo.fourmall.cart.config;

import com.fourforfo.fourmall.cart.interceptor.CartInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: fourmall
 * @description: 配置拦截器Interceptor等信息
 * @author: fourforfo
 * @email: fourforfo@gmail.com
 * @create: 2022-08-24 15:52
 **/

@Configuration
public class FourmallWebConfig  implements WebMvcConfigurer {

    //只有WebConfig中需要实例化一次，就不放到SpringBean中了
//    @Autowired
//    CartInterceptor cartInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //添加购物车拦截器
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }

}
